#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：saas 
@File    ：multi.py
@IDE     ：PyCharm 
@Author  ：janggui
@Date    ：2022/12/15 15:40 
'''

import random
from django.shortcuts import render, HttpResponse
from django import forms
from utils.tencent.sms import send_sms_single
from django.conf import settings
from app01 import models
# Create your views here.

# 发送短信


def send_sms(request):
    code = random.randrange(1000, 9999)
    sms_id = settings.SMS_ID.get("login")

    if not sms_id:
        return HttpResponse('模板不存在！')

    res = send_sms_single('15187488267', sms_id, [code,'3'])
    if res['result'] == 0:
        return HttpResponse('成功')
    else:
        return HttpResponse("成功！")

# 注册


class RegisterForm(forms.ModelForm):

    class Meta:
        model = models.UserInfo
        fields = "__all__"


def register(request):
    form = RegisterForm()
    # 多个APP需要新建父类目录来区分 'app01/register.html'，app01为父类
    return render(request, 'app01/register.html', {'form': form})



